package cn.changgou.search.controller;

import cn.changgou.entity.Result;
import cn.changgou.entity.StatusCode;
import cn.changgou.search.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/search")
@CrossOrigin
public class SkuController {

    @Autowired
    private SkuService skuService;

    /*关键词搜索*/
    @RequestMapping(method = RequestMethod.GET)
    public Map search(@RequestParam(required = false) Map<String, String> searchMap){
        return skuService.search(searchMap);
    }

    /*数据导入*/
    @RequestMapping(value = "/import", method = RequestMethod.GET)
    public Result importData(){
        skuService.importData();
        return new Result(true, StatusCode.OK, "执行操作成功！");
    }
}
